##
# @file CMakeLists.txt
# @brief main CMake
# @author JakeYang <add358@gmail.com>
# @version 0.1
# @date 2016-02-23
#

PROJECT(gjson)

CMAKE_MINIMUM_REQUIRED(VERSION 1.0)

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(CMAKE_MODULE_PATH ${CMAKE_ROOT}/Modules ${PROJECT_SOURCE_DIR}/cmake)

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib)

AUX_SOURCE_DIRECTORY(lib CJSON_SRCS)

ADD_DEFINITIONS(-g)

ADD_EXECUTABLE(international test/international.c ${CJSON_SRCS})
ADD_EXECUTABLE(show test/show.c ${CJSON_SRCS})
ADD_EXECUTABLE(misc test/misc.c ${CJSON_SRCS})

FIND_PACKAGE(glib2 REQUIRED)
MARK_AS_ADVANCED(
        glib2_INCLUDE_DIRS
        glib2_LIBRARIES
        )

INCLUDE_DIRECTORIES(${glib2_INCLUDE_DIRS})

TARGET_LINK_LIBRARIES(international m ${glib2_LIBRARIES})
TARGET_LINK_LIBRARIES(show m ${glib2_LIBRARIES})
TARGET_LINK_LIBRARIES(misc m ${glib2_LIBRARIES})

ENABLE_TESTING()
ADD_TEST(international ${PROJECT_BINARY_DIR}/bin/international ${PROJECT_SOURCE_DIR}/test/chinese.json)
ADD_TEST(show ${PROJECT_BINARY_DIR}/bin/show ${PROJECT_SOURCE_DIR}/test/misc.json)
ADD_TEST(test1 ${PROJECT_BINARY_DIR}/bin/show ${PROJECT_SOURCE_DIR}/test/misc.json)

FIND_PACKAGE(glib2 REQUIRED)
